package com.tencent.qplus.paddata.stat;

import org.apache.log4j.Logger;

import com.tencent.qplus.paddata.util.DateUtils;
import com.tencent.qplus.paddata.util.MailAlarm;


public abstract class Job {
	
	public DateUtils dateUtils = new DateUtils();
	public String statDate = dateUtils.getDateStrByDays(-1);
	
	public Logger logger = Logger.getLogger(this.getClass());
	
	public void stat(String[] args){
		if(args!=null && args.length==1 && dateUtils.isDateStr(args[0])){
			this.statDate = args[0];
		}
		String baseName = getClass().getSimpleName();
		logger.info(baseName + " start..................: "+statDate);
		try {
			run();
		} catch (Exception e) {
			MailAlarm.alarm(e);
			logger.info(baseName+ " failed ..................: "+statDate);
		}
		logger.info(baseName+ " done..................: "+statDate);
	}
	public abstract void run() throws Exception;
	public abstract void init()  throws Exception;
}
